package com.szxw.BaiduAi.service;

import com.baidu.aip.ocr.AipOcr;
import com.szxw.BaiduAi.factory.ApiFactory;
import org.json.JSONObject;

import java.util.HashMap;

/**
 * @Author: 苏执小威
 * @Email:1410511702@qq.com
 * @Desc:
 * @Date: 2022/9/24 17:04
 */
public class OcrService {
    public OcrService(){
    }
    private static AipOcr ocr = ApiFactory.getOcrInstance();
    private static   HashMap<String, String> options = new HashMap<String, String>();


    /**
     * 该方法用于实现 通用文字识别功能
     * @param text
     * @return
     */
    public static JSONObject basicAccurateGeneral(byte[] text){
        options.put("detect_direction", "false");
        options.put("probability", "false");
        return ocr.basicAccurateGeneral(text,options);
    }
    /**
     * 该方法用于实现银行卡识别
     * @param text
     * @return
     */
    public static JSONObject bankcard(byte[] text){
        return ocr.bankcard(text,options);
    }

}
